﻿namespace PortableRiotGames.Fluent.Summoner
{
    using PortableRiotGames.Infrastructure;
    using PortableRiotGames.Interfaces.Summoner;
    using System;
    using System.ComponentModel;

    public class SummonerBuilderHandler
    {
        /// <summary>
        /// Get mastery pages by summoner ID.
        /// </summary>
        /// <param name="summonerID">ID of the summoner for which to retrieve mastery pages.</param>
        /// <returns></returns>
        public RiotGamesGenericBuilder<GetMasteriesRequest, GetMasteriesResponse> GetMasteries(long summonerID)
        {
            return new RiotGamesGenericBuilder<GetMasteriesRequest, GetMasteriesResponse>(new GetMasteriesRequest(RiotGamesWebAPI.DeveloperKey) { SummonerID = summonerID });
        }

        /// <summary>
        /// Get rune pages by summoner ID.
        /// </summary>
        /// <param name="summonerID">ID of the summoner for which to retrieve rune pages.</param>
        /// <returns></returns>
        public RiotGamesGenericBuilder<GetRunesRequest, GetRunesResponse> GetRunes(long summonerID)
        {
            return new RiotGamesGenericBuilder<GetRunesRequest, GetRunesResponse>(new GetRunesRequest(RiotGamesWebAPI.DeveloperKey) { SummonerID = summonerID });
        }

        /// <summary>
        /// Get summoner by name.
        /// </summary>
        /// <param name="name">Name of summoner to retrieve.</param>
        /// <returns></returns>
        public RiotGamesGenericBuilder<GetSummonerRequest, GetSummonerResponse> GetSummoner(string name)
        {
            return new RiotGamesGenericBuilder<GetSummonerRequest, GetSummonerResponse>(new GetSummonerRequest(RiotGamesWebAPI.DeveloperKey) { SummonerName = name });
        }

        /// <summary>
        /// Get summoner by summoner ID.
        /// </summary>
        /// <param name="summonerID">ID of the summoner to retrieve.</param>
        /// <returns></returns>
        public RiotGamesGenericBuilder<GetSummonerRequest, GetSummonerResponse> GetSummoner(long summonerID)
        {
            return new RiotGamesGenericBuilder<GetSummonerRequest, GetSummonerResponse>(new GetSummonerRequest(RiotGamesWebAPI.DeveloperKey) { SummonerID = summonerID });
        }

        /// <summary>
        /// Get list of summoner names by summoner IDs.
        /// </summary>
        /// <param name="summonerIDs">List of summoner IDs associated with summoner names to retrieve. Maximum allowed at once is 40.</param>
        /// <returns></returns>
        public RiotGamesGenericBuilder<GetSummonersRequest, GetSummonersResponse> GetSummoners(params long[] summonerIDs)
        {
            if (summonerIDs.Length > 40)
            {
                throw new ArgumentException("Maximum allowed summoner IDs at once is 40.");
            }

            var ids = summonerIDs.ToDelimitedString(",");
            return new RiotGamesGenericBuilder<GetSummonersRequest, GetSummonersResponse>(new GetSummonersRequest(RiotGamesWebAPI.DeveloperKey) { SummonerIDs = ids });
        }

        #region Hidden

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public new Type GetType()
        {
            return this.GetType();
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string ToString()
        {
            return base.ToString();
        }

        #endregion Hidden
    }
}
